package com.ihighest.app.infox.activity;

import android.os.Bundle;
import android.util.Log;
import android.widget.ListView;

import com.ihighest.app.common.api.Api;
import com.ihighest.app.common.api.ApiCallback;
import com.ihighest.app.common.api.ApiParam;
import com.ihighest.app.common.api.ApiResult;
import com.ihighest.app.infox.R;
import com.ihighest.app.infox.adapter.WikiClassListAdapter;
import com.ihighest.app.infox.myview.ActivityTitle;

/**
 * 百科分类列表界面
 * 
 * @author Vity Created at 2015-10-22 上午12:05:41
 * @version 1.0
 */
public class WikiClassActivity extends BaseActivity {
	final String TAG = "WikiClassActivity";
	ActivityTitle title;
	ListView listView;
	WikiClassListAdapter adapter;
	String id;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.infox_activity_wiki_class);
		id = getIntent().getStringExtra("id");
		initView();
	}

	/**
	 * 初始化界面
	 * 
	 * 
	 * @author Vity Created at 2015-10-22 上午12:06:47
	 */
	public void initView() {
		title = (ActivityTitle) findViewById(R.id.activityTitle);
		title.setTitle("百科内容");
		title.setViewVersible(title.titleBack);
		title.setViewGone(title.titleMsg, title.titleRefresh, title.rightText);
		listView = (ListView) findViewById(R.id.listView);
		adapter = new WikiClassListAdapter(this);
		listView.setAdapter(adapter);
	}

	/**
	 * 加载数据
	 * 
	 * @author Vity Created at 2015-10-22 上午12:09:45
	 */
	public void loadData() {
		Api.get("wiki/subs", ApiParam.create().addParam("id", id), new ApiCallback(this, true) {

			@Override
			public void handleSuccess(ApiResult result) {
				adapter.setDatas(result.getDatas());
				adapter.notifyDataSetChanged();
			}

			@Override
			public void handleFailure(Exception e, String msg) {
				Log.e(TAG, e.getMessage(), e);
			}
		}, this);

	}
}
